import request from '@/router/axios';

export const getAreaListByLevel = (parentId,level) => {
    return request({
        url: '/base/area/getAreaListByLevel',
        method: 'post',
        params: {
            parentId,
            level,
        }
    })
}



export const getOrganizationListByLevel = (parentId,level) => {
    return request({
        url: '/base/organization/getOrganizationListByLevel',
        method: 'post',
        params: {
            parentId,
            level,
        }
    })
}

export const getList = (page, size, params) => {
  return request({
    url: '/base/area/list',
    method: 'post',
    params: {
      ...params,
      page,
      size,
    }
  })
}

export const getListTree = () => {
    return request({
        url: '/base/area/getTreeSelect',
        method: 'post'
    })
}

export const remove = (id) => {
  return request({
    url: '/base/area/delete',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      id,
    }
  })
}
export const removeAll = (areaStr) => {
  return request({
    url: '/base/area/deleteAll',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      areaStr,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/base/area/addItem',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/base/area/editItem',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: row
  })
}

export const bindArea = (areaIds,transAreaId) => {
    return request({
        url: '/base/area/bindArea',
        method: 'post',
        meta: {
            isSerialize: true,
        },
        data: {
            areaIds,
            transAreaId
        }
    })
}

export const showBack = (id) => {
    return request({
        url: '/base/area/showBack',
        method: 'post',
        meta: {
            isSerialize: true,
        },
        data: {
            transAreaId:id
        }
    })
}

export const changeStatus = (userId, status) => {
  return request({
    url: '/base/area/changeStatus',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      userId,
      status
    }
  })
}
export const updateDisplay = (id, common) => {
  // 这里common如果是boolean类型,无法传入后台,待以后优化吧
  return request({
    url: '/base/area/updateDisplay',
    method: 'post',
    meta: {
      isSerialize: true,
    },
    data: {
      id,
      common
    }
  })
}